package com.huanxing.cloud.upms.admin.controller;

import cn.hutool.json.JSONUtil;
import com.google.common.collect.Lists;
import com.huanxing.cloud.common.core.entity.R;
import com.huanxing.cloud.common.security.entity.HuanxingUser;
import com.huanxing.cloud.common.security.utils.SecurityUtils;
import com.huanxing.cloud.upms.common.entity.SysMenu;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/** @Author lijx @Date 2022/1/27 16:33 */
@RestController
@RequestMapping("/menu")
@Slf4j
public class SysMenuController {

  @GetMapping("/getMenu")
  public R getMenu() {
    HuanxingUser huanxingUser = SecurityUtils.getUser();
    log.info(JSONUtil.toJsonStr(huanxingUser));
    List<SysMenu> sysMenuList = Lists.newArrayList();
    SysMenu sysMenu = new SysMenu();
    sysMenu.setId("1");
    sysMenu.setType("1");
    sysMenu.setName("平台管理");
    sysMenu.setLabel("平台管理");
    sysMenu.setComponent("Layout");
    sysMenu.setIcon("icon-pingtaiguanli");
    sysMenu.setParentId("0");
    sysMenu.setPath("/system");
    sysMenu.setSort(1);
    List<SysMenu> sysMenus = Lists.newArrayList();
    SysMenu sysMenu2 = new SysMenu();
    sysMenu2.setId("2");
    sysMenu2.setType("1");
    sysMenu2.setName("租户管理");
    sysMenu2.setLabel("租户管理");
    sysMenu2.setComponent("views/upms/tenant/index");
    sysMenu2.setIcon("icon-navicon-zhgl");
    sysMenu2.setParentId("1");
    sysMenu2.setPath("/tenant");
    sysMenu2.setSort(1);
    sysMenus.add(sysMenu2);
    SysMenu sysMenu3 = new SysMenu();
    sysMenu3.setId("3");
    sysMenu3.setType("1");
    sysMenu3.setName("关于");
    sysMenu3.setLabel("关于");
    sysMenu3.setComponent("views/upms/about/index");
    sysMenu3.setIcon("icon-caidanguanli");
    sysMenu3.setParentId("1");
    sysMenu3.setPath("/about");
    sysMenu3.setSort(1);
    sysMenus.add(sysMenu3);
    sysMenu.setChildren(sysMenus);
    sysMenuList.add(sysMenu);
    return R.success(sysMenuList);
  }
}
